from APIs.baseAPI import BaseAPI
from common.config import ip
import requests


class Login(BaseAPI):
    def login(self,mydata):
        # mydata = {"username": "admin", "password": "123456"}
        # {"username": "admin", "password": "123456"}
        # {"username": "admin", "password": "123456", "idd": "500"}

        r = requests.post(f"{ip}/login", data=mydata)
        myJSON = r.json()
        code = myJSON['code']
        return code
    def get_token(self):
        mydata = {"username": "admin", "password": "123456"}
        r = requests.post(f"{ip}/login", data=mydata)
        myJSON = r.json()
        token = myJSON['Admin-Token']
        return token

if __name__ == '__main__':
    a = Login().get_token()
    print(a)
